/*
 * Copyright (c) 2020 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <stdio.h>
#include <unistd.h>

#include "cmsis_os2.h"
#include "ohos_init.h"
#include "los_interrupt.h"
#include "los_task.h"


static void interrupt_handler(HWI_ARG_T arg){
    printf("---interrupt handler---\n");
}

void interrupt_entry(void){
    uint32_t ret;
    printf("---intertupt demo---\n");

    HWI_HANDLE_T irq_num = 13;
    HwiIrqParam param;
    param.pDevId = 1;   // 设备号,为共享中断设计，目前可忽略
    param.swIrq = irq_num;   
    // 创建中断, 中断号、优先级、忽略，中断处理函数、参数
    ret = LOS_HwiCreate(irq_num, 3, 0,  (HWI_PROC_FUNC)interrupt_handler, &param);
    if (ret != LOS_OK) {
        printf("create hwi %d err1 %x\n", irq_num,ret);
        return;
    }
    osDelay(500);
    printf("---trigger interrupt---\n");
    LOS_HwiTrigger(irq_num);
}


//APP_FEATURE_INIT(interrupt_entry);